package com.yangrui.app.mapper;

import com.yangrui.app.entity.VideoBanner;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VideoBannerMapper {

    @Select("SELECT id,url,src,weight,create_time FROM video_banner")
    List<VideoBanner> list();

    /**
     * 插入数据
     * @param videoBanner 实体
     * @return 状态
     */
    @Insert("INSERT INTO lesson.video_banner(url, src, weight) VALUES (#{url},#{src},#{weight})")
    int insert(VideoBanner videoBanner);
    /**
     * 修改数据
     * @param videoBanner 实体
     * @return 状态
     */
    @Update("UPDATE `lesson`.`video_banner` SET `url` = #{url}, `src` = #{src}, `weight` = #{weight} WHERE `id` = #{id}")
    int updateById(VideoBanner videoBanner);

    /**
     * 删除
     * @param id id
     * @return 状态
     */
    @Delete("DELETE FROM `lesson`.`video_banner` WHERE id = #{id}")
    int deleteById(Integer id);

    /**
     * 根据id查询
     * @param id id
     * @return 实体
     */
    @Select("SELECT id,url,src,weight,create_time FROM video_banner WHERE id = #{id}")
    VideoBanner selectById(Integer id);

    /**
     * 全查
     */
    @Select("SELECT id,url,src,weight,create_time FROM video_banner")
    List<VideoBanner> selectAll();

}
